<!DOCTYPE html>
<html>
<head>
    <meta charset="UTF-8">
    <title>WISSC轮滑教培服务网-查询系统</title>
	<#assign base=request.contextPath  />
    <link rel="icon" href="${base}/favicon.ico">
    <link rel="stylesheet" href="${base}/frame/layui/css/layui.css">
    <script src="${base}/frame/layui/layui.js" charset="utf-8"></script>
    <script type="text/javascript" src="${base}/js/ztree/jquery-1.4.4.min.js"></script>
    <script src="${base}/js/jquery.min.js"></script>
    <script type="text/javascript" src="${base}/js/feng.js"></script>
    <link rel="stylesheet" type="text/css" href="${base}/css/hzw-city-picker.css">
    <script type="text/javascript" src="${base}/js/city-data.js"></script>
    <script type="text/javascript" src="${base}/js/hzw-city-picker.min.js"></script>
</head>
<body>
<form class="layui-form" action="" style="margin: 10px">
    <input type="hidden" id="id" value="${model!''}"/>
    <div class="layui-inline">
        <label class="layui-form-label"><a style="color:red">*</a>&nbsp;配置类型</label>
        <div class="layui-input-inline">
            <input readonly="true" name="type" id="type" lay-verify="required" autocomplete="off" class="layui-input isNull"
                   type="text">
        </div>
    </div>
    <div class="layui-upload">
        <button type="button" class="layui-btn" id="test1" style="background-color: #0092EF;">网页顶端图片上传</button>
        <div class="layui-upload-list" id="url">
            <img class="layui-upload-img " name="demo1" id="demo1" style="width:70px;height:70px">
            <p id="demoText"></p>
        </div>
    </div>
    <div class="layui-form-item">
        <div class="layui-input-inline">
            <button class="layui-btn " lay-submit lay-filter="formDemo" type="button"
                    onclick="onSubmit()" style="background-color: #0092EF;">立即提交
            </button>
            <button type="reset" class="layui-btn layui-btn-primary layui-btn-radius">重置</button>
        </div>
    </div>
</form>

<script>
    var a;
    layui.use('upload', function () {

        var $ = layui.jquery
            , upload = layui.upload;
        //普通图片上传
        var uploadInst = upload.render({
            elem: '#test1'
            , url: '${base}/file/uploadFile'
            , before: function (obj) {
                //预读本地文件示例，不支持ie8
                obj.preview(function (index, file, result) {
                    $('#demo1').attr('src', result); //图片链接（base64）
                });
            }
            , done: function (res) {

                //上传成功
                a = res.data;

                return res.data;
            }
            , error: function () {
                //演示失败状态，并实现重传
                var demoText = $('#demoText');
                demoText.html('<span style="color: #FF5722;">上传失败</span> <a class="layui-btn layui-btn-xs demo-reload">重试</a>');
                demoText.find('.demo-reload').on('click', function () {
                    uploadInst.upload();
                });
            }
        });
    })
</script>


    <script type="text/javascript">

        layui.use(['form', 'layedit', 'laydate','layer'], function(){
            var form = layui.form
                    ,layer = layui.layer
                    ,layedit = layui.layedit
                    ,laydate = layui.laydate;



        });

    </script>
<script>
    //编辑
    function onSubmit() {

        var jsonDate = {};
        jsonDate.type = $("#type").val();
        jsonDate.parameter = a;

        jsonDate.id = $("#id").val();
        if(jsonDate.parameter!=null&&jsonDate.parameter!=""){
            $.ajax({
                type:"POST",
                traditional: true,
                contentType: "application/json;charset=UTF-8",
                url:"${base}/webPage/webPage_edit",
                data:JSON.stringify(jsonDate),
                success:function(data){

                    layer.msg("修改成功");
                    setTimeout(function(){
                        var index = parent.layer.getFrameIndex(window.name); //先得到当前iframe层的索引
                        parent.layer.close(index); //再执行关闭

                    },300)
                    var table = parent.layui.table;
                    //表刷新方法
                    table.reload('testReload', {
                        url: '${base}/webPage/selectMyPage'//数据接口
                        , where: {} //设定异步数据接口的额外参数
                        //,height: 300
                    });
                }

            });
        }else{
            layer.msg("请上传图片");
        }





    }


</script>

</body>
</html>
